package reduce.fz.com.reduce.service;

import android.content.Context;

import java.util.HashMap;

import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.abstracts.AbResponseListener;
import reduce.fz.com.reduce.bean.Society;
import reduce.fz.com.reduce.bean.SocietyNotice;
import reduce.fz.com.reduce.bean.page.Pagination;
import reduce.fz.com.reduce.util.ApiUtil;
import reduce.fz.com.reduce.util.HttpUtils;
import reduce.fz.com.reduce.util.base.ReduceApplication;

/**
 * Created by qingshengzheng on 16/1/26.
 */
public class SocietyService {

    private Context context;

    public SocietyService(Context context) {
        this.context = ReduceApplication.getInstance().getBaseContext();
    }

    public void applyJoin(Long sid, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_society_join);
        HashMap map = new HashMap();
        map.put("sid", sid + "");
        HttpUtils.jsonPost(url, map, listener);
    }


    public void createSociety(Society society, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_society_add);
        HttpUtils.jsonPost(url, society, listener);
    }

    public void getJoinedSocietyNum(AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_user_societynum);
        HttpUtils.get(url, listener);
    }

    public void getSociety(Long sid, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_society_detail, sid);
        HttpUtils.get(url, listener);
    }

    public void quit(Long sid, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_society_quit, sid);
        HttpUtils.get(url, listener);
    }


    public void joinSociety(Long sid, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_society_join,sid);
        HttpUtils.get(url, listener);
    }

    public void getTopMember(Long sid, int count, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_society_contribution, sid, 1, count);
        HttpUtils.get(url, listener);
    }

    public void getTopDynamic(Long sid, int count, AbResponseListener listener) {
        String url = ApiUtil.getApi(context, R.array.api_society_dynamic, sid, 1, count);
        HttpUtils.get(url, listener);
    }

    public void addSocietyNotice(SocietyNotice notice, AbResponseListener listener) {

        String url = ApiUtil.getApi(context, R.array.api_societynotice_add);
        HttpUtils.jsonPost(url, notice, listener);
    }


}
